<template>
	<div>
		<!-- <h1>首页</h1>
		{{count}}
		<button @click="handleIncrement">+</button>
		<button @click="handleDecrease">-</button> -->
		随机增加:
		  <Counter :number="number"></Counter>
	</div>
</template>
<script>
	
	import Counter from './Counter.vue'
	
	export default {
		components:{
			Counter
		},
		methods:{
			handleAddRandom(num){
				this.number += num;
			}
		},
		data(){
			return{
				number:0
			}
		},
		created() {
			this.$bus.on('add', this.handleAddRandom)
		},
		beforeDestroy() {
			this.$bus.off('add',this.handleAddRandom)
		}
	}
</script>
